package com.woniu.supermarket.web;


import com.woniu.supermarket.entity.Shop;
import com.woniu.supermarket.result.ResultResponse;
import com.woniu.supermarket.service.IShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("shop")
@Api(value = "店铺的操作")
public class ShopController {
    @Autowired
    IShopService iShopService;
    
    
    //查询所有店铺
    @GetMapping("/all")
    @ApiOperation(value = "查询所有店铺")
    public ResultResponse<List<Shop>> allList(){

        ResultResponse<List<Shop>> result = null;

        try {
            List<Shop> lists = iShopService.findAll();
            result = new ResultResponse<>(200,"查询所有店铺成功!",lists);
        }catch (RuntimeException e){
            e.printStackTrace();
            result = new ResultResponse<>(201,"查询所有店铺失败!");
        }
        return result ;
    }

}
